package com.zhiche.lisa.bms.service.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.zhiche.lisa.bms.dao.model.interfacelog.InterfaceLog;
import com.zhiche.lisa.bms.dao.model.price.PriceIncomeLog;
import com.zhiche.lisa.bms.dao.model.price.PricePurchaseDtl;
import com.zhiche.lisa.bms.enums.RateTransformEnum;
import com.zhiche.lisa.bms.pojo.dto.fee.FeeAssessmentAndRewardDTO;
import com.zhiche.lisa.bms.pojo.dto.pay.PayApplyToBmsBill;
import com.zhiche.lisa.bms.pojo.dto.util.*;
import com.zhiche.lisa.bms.pojo.dto.util.integration.ShipTaskDTO;
import com.zhiche.lisa.bms.pojo.dto.util.integration.ShipmentDTO;
import com.zhiche.lisa.bms.service.price.PriceIncomeLogService;
import com.zhiche.lisa.bms.service.utils.common.BeanColumnUtil;
import com.zhiche.lisa.core.supports.BaseException;
import com.zhiche.lisa.core.supports.RestfulResponse;
import com.zhiche.lisa.core.utils.HttpClientUtil;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;

import java.math.BigDecimal;
import java.util.*;

@Component
public class OtmUtil {

    private static final Logger LOGGER = LoggerFactory.getLogger(OtmUtil.class);

    @Value("${lisa.integration.url}")
    private String url;

    @Value("${lisa.integration.exportPriceURL}")
    private String exportPriceURL;

    @Value("${lisa.integration.getOtmShipment}")
    private String getOtmShipment;

    @Value("${lisa.integration.getOtmShipmentDTL}")
    private String getOtmShipmentDTL;

    @Value("${lisa.outsideBMS.custBillLogURL}")
    private String custBillLogURL;

    @Value("${lisa.outsideBMS.assessmentURL}")
    private String assessmentURL;

    @Value("${lisa.outsideBMS.capitalFourURL}")
    private String capitalFourURL;

    @Value("${lisa.outsideBMS.invoiceCreateURL}")
    private String invoiceCreateURL;

    @Value("${lisa.outsideBMS.syncRedURL}")
    private String syncRedURL;

    @Value("${lisa.outsideBMS.delFlagURL}")
    private String delFlagURL;

    @Value("${lisa.socketTimeout}")
    private Integer socketTimeout;

    @Value("${lisa.outsideBMS.token}")
    private String outsideToken;

    @Value("${lisa.outsideBMS.url}")
    private String outsideUrl;

    @Value("${lisa.otmHandler.url}")
    private String otmHandlerUrl;

    @Value("${lisa.otmHandler.getSavePriceByRs}")
    private String getSavePriceByRs;

    @Value("${lisa.otmHandler.getStdPrice}")
    private String getStdPriceUrl;


    @Value("${lisa.outsideBMS.payApplyToBms}")
    private String payApplyToBms;

    /**
     * 更新考核单和奖励单
     */
    @Value("${lisa.outsideBMS.assessmentAndRewardUpdate}")
    private String assessmentAndRewardUpdate;
    /**
     * 查询otm运单状态
     */
    @Value("${lisa.otmHandler.queryBatchOrderReleaseStatus}")
    private String queryBatchOrderReleaseStatus;

    @Autowired
    private PriceIncomeLogService priceIncomeLogService;

    @Autowired
    private InterfaceLogUtil interfaceLogUtil;

    /**
     * 向主系统回写执行价格
     */
    public RestfulResponse<String> exportPrice(String itemSourceKey, BigDecimal incomingPrice, BigDecimal mileage, String token) throws BaseException {
        RestfulResponse<String> shipTaskVO = null;

        if (!StringUtils.hasText(itemSourceKey)) {
            throw new BaseException("委托单号，不能为空！");
        }
        if (ObjectUtils.isEmpty(incomingPrice)) {
            throw new BaseException("执行价格，不能为空！");
        }
        List<NameValuePair> headNamePairs = Lists.newArrayList();

        Map<String, String> paramsMap = Maps.newHashMap();
        paramsMap.put("orderlineId", itemSourceKey);
        paramsMap.put("oilCost", incomingPrice.toString());
        paramsMap.put("mileage", mileage.toString());

        // 发送请求给(中联结算系统)otm
        String otmUrl = url + exportPriceURL;
        String strReturn = HttpClientUtil.postJson(otmUrl, headNamePairs, JSON.toJSONString(paramsMap), socketTimeout);
        //调用OTM系统返回的结果，记录在日志表中
        PriceIncomeLog priceIncomeLog = new PriceIncomeLog();
        priceIncomeLog.setUrl(otmUrl);//请求地址
        priceIncomeLog.setItemSourceKey(itemSourceKey);//运输订单号，来源唯一键(存储otm releaseGid)
        priceIncomeLog.setKilometre(mileage);
        priceIncomeLog.setGmtCreate(new Date());
        priceIncomeLog.setActIncomingPrice(incomingPrice);//收入执行价
        priceIncomeLog.setParam(paramsMap.toString());//请求参数
        if (!StringUtils.isEmpty(strReturn)) {
            shipTaskVO = JSON.parseObject(strReturn, new TypeReference<RestfulResponse<String>>() {
            });
            int resultCode = shipTaskVO.getCode();//状态; 0-成功, 1-失败
            priceIncomeLog.setStatus(resultCode);
            priceIncomeLog.setResultMsg(shipTaskVO.getMessage());//返回信息
            int failCount = resultCode != 0 ? 1 : 0;//错误回调次数
            priceIncomeLog.setNum(failCount);

        } else {
            priceIncomeLog.setStatus(-1);
            priceIncomeLog.setResultMsg("推送OTM无返回数据信息");
            priceIncomeLog.setNum(1);
        }
        priceIncomeLogService.insertPriceIncomeLog(priceIncomeLog);
        return shipTaskVO;
    }

    public List<ShipTaskDTO> getOtmShipmentDTL(String shipmentId, String orCode) {
        InterfaceLog interfaceLog = new InterfaceLog();
        List<ShipTaskDTO> returnVal = null;
        try {
            if (Strings.isNullOrEmpty(shipmentId)) {
                return null;
            }
            List<NameValuePair> headNamePairs = Lists.newArrayList();

            List<NameValuePair> params = Lists.newArrayList();
            params.add(new BasicNameValuePair("shipmentId", shipmentId));
            if (!StringUtils.isEmpty(orCode)) {
                params.add(new BasicNameValuePair("ORCode", orCode));
            }

            String otmUrl = url + getOtmShipmentDTL;
            interfaceLogUtil.setCallerPartyCommonLog(interfaceLog, params, otmUrl);
            String strReturn = HttpClientUtil.get(otmUrl, headNamePairs, params, socketTimeout);
            interfaceLogUtil.setCallPartySuccessLog(interfaceLog, strReturn);
            if (!StringUtils.isEmpty(strReturn)) {
                RestfulResponse<List<ShipTaskDTO>> restfulResponse =
                        JSON.parseObject(strReturn, new TypeReference<RestfulResponse<List<ShipTaskDTO>>>() {
                        });
                if (Objects.nonNull(restfulResponse) && Objects.nonNull(restfulResponse.getData())) {
                    returnVal = restfulResponse.getData();
                }
            }
            interfaceLogUtil.setSuccessLog(interfaceLog);
        } catch (Exception e) {
            interfaceLogUtil.setErrorLog(interfaceLog, e.getMessage());
        } finally {
            interfaceLogUtil.saveInterfaceLog(interfaceLog);
        }
        return returnVal;
    }

    public ShipmentDTO getOtmShipment(String shipmentId) {
        ShipmentDTO returnVal = null;
        String otmUrl = url + getOtmShipment;
        try {
            if (Strings.isNullOrEmpty(shipmentId)) {
                return null;
            }
            List<NameValuePair> headNamePairs = Lists.newArrayList();

            Map<String, String> params = Maps.newHashMap();
            params.put("shipmentId", shipmentId);

            LOGGER.info(otmUrl + "-->GET(url:{},param:{})", otmUrl, params);
            String strReturn = HttpClientUtil.post(otmUrl, headNamePairs, params, socketTimeout);
            if (!StringUtils.isEmpty(strReturn)) {
                RestfulResponse<ShipmentDTO> restfulResponse =
                        JSON.parseObject(strReturn, new TypeReference<RestfulResponse<ShipmentDTO>>() {
                        });
                if (Objects.nonNull(restfulResponse) && Objects.nonNull(restfulResponse.getData())) {
                    returnVal = restfulResponse.getData();
                }
            }
            LOGGER.info(otmUrl + "-->Success");
        } catch (Exception e) {
            LOGGER.error(otmUrl + "-->Error:" + e.getMessage());
        }
        return returnVal;
    }

    /**
     * 向主系统回写对账结果
     */
    public String billContrastResult(CustBillDTO custBillDTO) throws BaseException {
        String custBillDtoStr = JSONObject.toJSONString(custBillDTO);
        //List<NameValuePair> headNamePairs = Lists.newArrayList();
        //headNamePairs.add(new BasicNameValuePair("Authorization", outsideToken));
        // 发送请求
        //String strReturn = HttpClientUtil.postJson(outsideUrl + custBillLogURL, getOutsizeTokeHead(), custBillDtoStr, socketTimeout);
        InterfaceLog interfaceLog = new InterfaceLog();
        interfaceLogUtil.setCallerPartyCommonLog(interfaceLog, custBillDTO, outsideUrl + custBillLogURL);
        String strReturn = getOutsideResult(custBillLogURL, custBillDtoStr);
        LOGGER.info("OtmUtil.billContrastResult 推送BMS对账 url: {}, param: [], result: {}", custBillLogURL, custBillDtoStr, strReturn);
        interfaceLog.setResultData(strReturn);
        if (!StringUtils.isEmpty(strReturn)) {
            Map<String, String> shipTaskVO = JSON.parseObject(strReturn, new TypeReference<Map<String, String>>() {
            });
            if (!CollectionUtils.isEmpty(shipTaskVO)) {
                interfaceLogUtil.setCallPartySuccessLog(interfaceLog, shipTaskVO);
                if ("true".equals(shipTaskVO.get("success"))) {
                    interfaceLog.setResultMessage("对账成功");
                    interfaceLogUtil.saveInterfaceLog(interfaceLog);
                    return shipTaskVO.get("message");
                } else {
                    interfaceLog.setResultMessage("对账失败");
                    interfaceLogUtil.setErrorLog(interfaceLog, shipTaskVO.get("message"));
                    interfaceLogUtil.saveInterfaceLog(interfaceLog);
                    throw new BaseException("同步账单错误-->" + shipTaskVO.get("message"));
                }
            }
        } else {
            interfaceLogUtil.setErrorLog(interfaceLog, "对账失败, 无返回结果");
            interfaceLogUtil.saveInterfaceLog(interfaceLog);
            throw new BaseException("对账失败, BMS无返回结果");
        }
        return null;
    }

    /**
     * 向主系统同步考核单
     */
    public BmsServiceResult synchroAssessment(List<SynchroAssessmentDTO> synchroAssessmentDTOList) throws BaseException {
        String custBillDtoStr = JSON.toJSONString(synchroAssessmentDTOList);
        //List<NameValuePair> headNamePairs = Lists.newArrayList();
        //headNamePairs.add(new BasicNameValuePair("Authorization", outsideToken));
        // 发送请求
        //String strReturn = HttpClientUtil.postJson(outsideUrl + assessmentURL, getOutsizeTokeHead(), custBillDtoStr, socketTimeout);
        String strReturn = getOutsideResult(assessmentURL, custBillDtoStr);
        if (!StringUtils.isEmpty(strReturn)) {
            BmsServiceResult shipTaskVO = JSON.parseObject(strReturn, new TypeReference<BmsServiceResult>() {
            });
            return shipTaskVO;
        }
        return null;
    }

    /**
     * 排款申请同步推送
     *
     * @param capitalArrangeDTO
     * @return
     * @throws BaseException
     */
    public BmsServiceResult capitalToBmsService(CapitalArrangeDTO capitalArrangeDTO) throws BaseException {
        String capitalJson = JSONObject.toJSONString(capitalArrangeDTO);
        String strReturn = getOutsideResult(capitalFourURL, capitalJson);
        if (!StringUtils.isEmpty(strReturn)) {
            BmsServiceResult shipTaskVO = JSON.parseObject(strReturn, new TypeReference<BmsServiceResult>() {
            });
            return shipTaskVO;
        }
        return null;
    }

    /**
     * 发票同步推送
     *
     * @param invoiceApplyDTO
     * @return
     * @throws BaseException
     */
    public BmsServiceResult invoiceToBmsService(InvoiceApplyDTO invoiceApplyDTO) throws BaseException {
        String capitalJson = JSONObject.toJSONString(invoiceApplyDTO);
        String strReturn = getOutsideResult(invoiceCreateURL, capitalJson);
        if (!StringUtils.isEmpty(strReturn)) {
            BmsServiceResult shipTaskVO = JSON.parseObject(strReturn, new TypeReference<BmsServiceResult>() {
            });
            return shipTaskVO;
        }
        return null;
    }

    /**
     * 同步奖励单
     *
     * @param assessRedDTOList
     * @return
     * @throws BaseException
     */
    public BmsServiceResult syncRedURL(List<AssessRedDTO> assessRedDTOList) throws BaseException {
        String capitalJson = JSONObject.toJSONString(assessRedDTOList);
        String strReturn = getOutsideResult(syncRedURL, capitalJson);
        if (!StringUtils.isEmpty(strReturn)) {
            BmsServiceResult shipTaskVO = JSON.parseObject(strReturn, new TypeReference<BmsServiceResult>() {
            });
            return shipTaskVO;
        }
        return null;
    }

    /**
     * 禁用考核、奖励单
     *
     * @param assessRedDTOList
     * @return
     * @throws BaseException
     */
    public BmsServiceResult delFlagURL(List<AssessRedDTO> assessRedDTOList) throws BaseException {
        InterfaceLog interfaceLog = new InterfaceLog();
        String capitalJson = JSONObject.toJSONString(assessRedDTOList);
        interfaceLogUtil.setCallerPartyCommonLog(interfaceLog, capitalJson, otmHandlerUrl + delFlagURL);
        String strReturn = getOutsideResult(delFlagURL, capitalJson);
        if (!StringUtils.isEmpty(strReturn)) {
            interfaceLogUtil.setCallPartySuccessLog(interfaceLog, strReturn);
            interfaceLogUtil.saveInterfaceLog(interfaceLog);
            BmsServiceResult shipTaskVO = JSON.parseObject(strReturn, new TypeReference<BmsServiceResult>() {
            });
            return shipTaskVO;
        }
        return null;
    }

    ///**
    // * 统一设置请求头
    // * @return
    // */
    //private List<NameValuePair> getOutsizeTokeHead() {
    //    List<NameValuePair> headNamePairs = Lists.newArrayList();
    //    headNamePairs.add(new BasicNameValuePair("Authorization", outsideToken));
    //    return headNamePairs;
    //}

    /**
     * 返回请求数据
     *
     * @param businessUrl 业务请求地址
     * @param param       参数json格式
     * @return
     */
    private String getOutsideResult(String businessUrl, String param) {
        InterfaceLog interfaceLog = new InterfaceLog();
        interfaceLogUtil.setCallerPartyCommonLog(interfaceLog, param, outsideUrl + invoiceCreateURL);
        List<NameValuePair> headNamePairs = Lists.newArrayList();
        headNamePairs.add(new BasicNameValuePair("Authorization", outsideToken));
        String result = HttpClientUtil.postJson(outsideUrl + businessUrl, headNamePairs, param, socketTimeout);
        if (StringUtils.isEmpty(result)) {
            interfaceLog.setResultSuccess(0);
            interfaceLog.setResultMessage("无返回数据");
            interfaceLogUtil.setCallPartySuccessLog(interfaceLog, result);
        } else {
            interfaceLogUtil.setCallPartySuccessLog(interfaceLog, result);
        }
        interfaceLogUtil.saveInterfaceLog(interfaceLog);
        return result;
    }

    /**
     * 惠运车-回写价格
     *
     * @param pricePurchaseDtl 支付价格明细
     * @return
     */
    public BmsServiceResult getSavePriceByRs(PricePurchaseDtl pricePurchaseDtl, String oilType) {
        InterfaceLog interfaceLog = new InterfaceLog();
        // // 慧运车扣点
        BigDecimal fiRate = RateTransformEnum.OTHER_RATE.getRate();
        // 总运费
        if (Objects.nonNull(pricePurchaseDtl.getSumCost())) {
            pricePurchaseDtl.setSumCost(pricePurchaseDtl.getSumCost().multiply(fiRate).setScale(2, BigDecimal.ROUND_HALF_UP));
        }

        Map<String, Object> map = BeanColumnUtil.objectToMap(pricePurchaseDtl, true);
        map.put("orderCode", pricePurchaseDtl.getOrderlineId());
        map.put("orderlineId", (pricePurchaseDtl.getOrderlineId() == null) ? "" : ("ULC/ZC." + pricePurchaseDtl.getOrderlineId()));
        map.put("oilType", oilType);

        String param = JSONObject.toJSONString(map);
        interfaceLogUtil.setCallerPartyCommonLog(interfaceLog, param, otmHandlerUrl + getSavePriceByRs);
        String result = HttpClientUtil.postJson(otmHandlerUrl + getSavePriceByRs, Lists.newArrayList(), param, socketTimeout);
        if (StringUtils.isEmpty(result)) {
            interfaceLog.setResultMessage("无返回数据");
        } else {
            interfaceLogUtil.setCallPartySuccessLog(interfaceLog, result);
        }
        interfaceLogUtil.saveInterfaceLog(interfaceLog);
        if (!StringUtils.isEmpty(result)) {
            BmsServiceResult shipTaskVO = JSON.parseObject(result, new TypeReference<BmsServiceResult>() {
            });
            return shipTaskVO;
        }
        return null;
    }

    /**
     * 获取标准价
     *
     * @param orCode
     * @return
     */
    public OtmServiceResult getStdPrice(String orCode) {
        InterfaceLog interfaceLog = new InterfaceLog();
        Map<String, Object> map = new HashMap<>();
        map.put("orderno", orCode);

        String param = JSONObject.toJSONString(map);
        interfaceLogUtil.setCallerPartyCommonLog(interfaceLog, param, otmHandlerUrl + getStdPriceUrl);
        String result = HttpClientUtil.postJson(otmHandlerUrl + getStdPriceUrl, Lists.newArrayList(), param, socketTimeout);
        interfaceLogUtil.setCallPartySuccessLog(interfaceLog, result);
        interfaceLogUtil.saveInterfaceLog(interfaceLog);
        if (!StringUtils.isEmpty(result)) {
            OtmServiceResult shipTaskVO = JSON.parseObject(result, new TypeReference<OtmServiceResult>() {
            });
            return shipTaskVO;
        }
        return null;
    }

    /**
     * 获取标准价
     * 无日志
     *
     * @param orCode
     * @return
     */
    public OtmServiceResult getStdPriceNoInterfaceLog(String orCode) {
        Map<String, Object> map = new HashMap<>();
        map.put("orderno", orCode);
        String param = JSONObject.toJSONString(map);
        String result = HttpClientUtil.postJson(otmHandlerUrl + getStdPriceUrl, Lists.newArrayList(), param, socketTimeout);
        if (!StringUtils.isEmpty(result)) {
            OtmServiceResult shipTaskVO = JSON.parseObject(result, new TypeReference<OtmServiceResult>() {
            });
            return shipTaskVO;
        }
        return null;
    }

    /**
     * 获取标准价
     *
     * @param orderNo
     * @return
     */
    public Map<String, Double> getStdPriceMap(String orderNo) {
        Map<String, Double> mapDouble = Maps.newHashMap();
        // InterfaceLog interfaceLog = new InterfaceLog();
        Map<String, String> map = Maps.newHashMap();
        map.put("orderno", orderNo);
        String param = JSONObject.toJSONString(map);
        // interfaceLogUtil.setCallerPartyCommonLog(interfaceLog, param, otmHandlerUrl + getStdPriceUrl);
        String strReturn = HttpClientUtil.postJson(otmHandlerUrl + getStdPriceUrl, Lists.newArrayList(), param, socketTimeout);
        if (!StringUtils.isEmpty(strReturn)) {
            JSONObject jsonObject = JSON.parseObject(strReturn);
            boolean status = jsonObject.getBooleanValue("success");
            if (status) {
                Double price = jsonObject.getJSONObject("data").getDouble("price");
                mapDouble.put("price", price);
                Double miles = jsonObject.getJSONObject("data").getDouble("miles");
                mapDouble.put("miles", miles);
            }
        }
        return mapDouble;

    }


    /**
     * 支付申请审核推送bms, 自动出账
     *
     * @param payApplyToBmsBill
     * @return
     * @throws BaseException
     */
    public BmsServiceResult payApplyToBmsCreateBill(PayApplyToBmsBill payApplyToBmsBill) throws BaseException {
        String payApplyBillJson = JSONObject.toJSONString(payApplyToBmsBill);
        LOGGER.info("payApplyToBmsCreateBill 支付申请推送OTM json: {}", payApplyBillJson);
        String strReturn = getOutsideResult(payApplyToBms, payApplyBillJson);
        if (!StringUtils.isEmpty(strReturn)) {
            BmsServiceResult shipTaskVO = JSON.parseObject(strReturn, new TypeReference<BmsServiceResult>() {
            });
            return shipTaskVO;
        }
        return null;
    }

    /**
     * 封装参数
     *
     * @param assessCode
     * @param type
     * @param performSum
     * @param bmsSum
     * @return
     */
    public FeeAssessmentAndRewardDTO packageParamJson(String assessCode, Integer type, BigDecimal performSum, BigDecimal bmsSum) {
        if (Objects.isNull(bmsSum)) {
            bmsSum = BigDecimal.ZERO;
        }
        if (Objects.isNull(performSum)) {
            performSum = BigDecimal.ZERO;
        }
        FeeAssessmentAndRewardDTO feeAssessmentAndRewardDTO = new FeeAssessmentAndRewardDTO();
        // 单号
        feeAssessmentAndRewardDTO.setAssessCode(assessCode);
        // 类型
        feeAssessmentAndRewardDTO.setType(type);
        // 总金额
        if (BigDecimal.ZERO.compareTo(performSum) != 0) {
            feeAssessmentAndRewardDTO.setTotalMoney(performSum);
        } else if (BigDecimal.ZERO.compareTo(bmsSum) != 0) {
            feeAssessmentAndRewardDTO.setTotalMoney(bmsSum);
        }
        // 已使用金额
        feeAssessmentAndRewardDTO.setUsedMoney(bmsSum);
        // 剩余金额
        feeAssessmentAndRewardDTO.setLeftMoney(feeAssessmentAndRewardDTO.getTotalMoney().subtract(bmsSum));
        // 更新时间
        feeAssessmentAndRewardDTO.setUpdateTime(new Date());
        return feeAssessmentAndRewardDTO;
    }

    /**
     * 考核单和奖励单的更新
     *
     * @param feeAssessmentAndRewardList
     * @return
     * @throws BaseException
     */
    public BmsServiceResult assessmentAndRewardUpdate(List<FeeAssessmentAndRewardDTO> feeAssessmentAndRewardList) throws BaseException {
        InterfaceLog interfaceLog = new InterfaceLog();
        String objectJson = JSONArray.toJSONString(feeAssessmentAndRewardList);
        interfaceLogUtil.setCallerPartyCommonLog(interfaceLog, objectJson, otmHandlerUrl + assessmentAndRewardUpdate);
        String strReturn = getOutsideResult(assessmentAndRewardUpdate, objectJson);
        if (!StringUtils.isEmpty(strReturn)) {
            interfaceLogUtil.setCallPartySuccessLog(interfaceLog, strReturn);
            interfaceLogUtil.saveInterfaceLog(interfaceLog);
            BmsServiceResult shipTaskVO = JSON.parseObject(strReturn, new TypeReference<BmsServiceResult>() {
            });
            return shipTaskVO;
        }
        return null;
    }

    /**
     * 获取标准价
     *
     * @param orderReleaseXids
     * @return
     */
    public OtmServiceResult queryBatchOrderReleaseStatus(String orderReleaseXids) {
        // InterfaceLog interfaceLog = new InterfaceLog();
        JSONObject param = new JSONObject();
        param.put("orderReleaseGid", orderReleaseXids);

        // interfaceLogUtil.setCallerPartyCommonLog(interfaceLog, param.toJSONString(), otmHandlerUrl + queryBatchOrderReleaseStatus);
        String result = HttpClientUtil.postJson(otmHandlerUrl + queryBatchOrderReleaseStatus, Lists.newArrayList(), param.toJSONString(), socketTimeout);
        // interfaceLogUtil.setCallPartySuccessLog(interfaceLog, result);
        // interfaceLogUtil.saveInterfaceLog(interfaceLog);
        if (!StringUtils.isEmpty(result)) {
            OtmServiceResult shipTaskVO = JSON.parseObject(result, new TypeReference<OtmServiceResult>() {
            });
            return shipTaskVO;
        }
        return null;
    }

}
